/**
  @file     	DESIGNPATTERN_SimpleFactory.cpp
  @brief    	Define an interface for creating an object, and the package object is created
  @author  	arvin
  @version 	1.0   2012/12/12
 */
#include "stdafx.h"

#ifndef CXX_DESIGNPATTERN_SIMPLEFACTORY_H
#include "DESIGNPATTERN_SimpleFactory.h"
#endif

#ifndef CXX_PROFESSION_H
#include "Profession.h"
#endif

SimpleFactory* SimpleFactory::m_pInstance = NULL;


/**
* Construction
*
* @param VOID
* @return 
*/
SimpleFactory::SimpleFactory()
{
	DEBUG_PRINTF("");
}

/**
* Destruction
*
* @param VOID
* @return 
*/
SimpleFactory::~SimpleFactory()
{
	DEBUG_PRINTF("");
}

/**
* Instance
*
* @param VOID
* @return SimpleFactory*
* @note SimpleFactory
*/
SimpleFactory* 
SimpleFactory::Instance()
{
	DEBUG_PRINTF("");
	if (NULL == m_pInstance) {
		m_pInstance = new SimpleFactory;
	}
	return m_pInstance;
}


/**
* Destroy
*
* @param VOID
* @return VOID
* @note singleton
*/
VOID 
SimpleFactory::Destroy()
{
	DEBUG_PRINTF("");
	if (NULL != m_pInstance) {
		delete m_pInstance;
		m_pInstance = NULL;
	}
}

/**
* Create Profession
*
* @param VOID
* @return Profession* 
* @note Profession Type to identify the creating
*/
Profession* 
SimpleFactory::CreateProfession(PROFESSION_TYPE eProfession)
{
	DEBUG_PRINTF("");
	Profession* pProfession = NULL;
	switch (eProfession) {
	case PROFESSION_WARRIOR:
		pProfession = new Warrior;
		break;
	case PROFESSION_MASTER:
		pProfession = new Master;
		break;
	case PROFESSION_PRIEST:
		pProfession = new Priest;
		break;
	case PROFESSION_NONE:
	case PROFESSION_ALL:
	case PROFESSION_INVALID:
	default:
		break;
	}
	return pProfession;
}

/* EOF */